import { equals } from 'ramda'
import { DirectiveBinding } from 'vue'
interface RoleMenuResourceResponseDto {
    routeAlias?: string
    type?: number
    key?: string
    name?: string
    api?: string
}
export const auth = {
    mounted: (el: HTMLBaseElement, binding: DirectiveBinding) => {
        if (binding.value && binding.instance) {
            const roleMenuResourceDtoList: Array<RoleMenuResourceResponseDto> =
                (binding.instance?.$route?.meta.roleMenuResourceDtoList as RoleMenuResourceResponseDto[]) ?? []
            if (!roleMenuResourceDtoList.some((item) => equals(item.key, binding.value))) {
                el.parentNode && el.parentNode.removeChild(el)
            }
        }
    },
}
